/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/find-peak-element
   @Language: C++
   @Datetime: 19-11-21 15:27
   */

class Solution {
public:
	int findPeakElement(vector<int>& nums) {
		int i=0;
		for(int k, j=nums.size()-1; i<j;){
			k=(i+j)/2;
			if(nums[k]>nums[k+1]) j=k;
			else i=k+1;
		}
		return i;
	}
};
